﻿using ArtMath.Attribute;
using ArtMath.Component.Point;
using ArtMath.Data;
using ArtMath.Resource;
using System;
using System.ComponentModel;

namespace ArtMath.Component.Line
{
    /// <summary>
    /// 平行线
    /// </summary>
    [Serializable]
    public class ParallelLine : PointSlopeLineBase
    {
        StraightLineBase line;
        public ParallelLine(SketchPad pad, string name, StraightLineBase line, bool addToList = true) : base(pad, name, ToolTypeName.pxx, addToList)
        {
            InPoints = new PointBase[1];
            StraightLine = line;
        }
        [MultilingualCategory("Structure"), MultilingualDisplayName("StraightLine"), TypeConverter(typeof(ExpandableObjectConverter))]
        public StraightLineBase StraightLine
        {
            get { return line; }
            set
            {
                line?.OutChildren_Line.Remove(this);
                line = value;
                if (line != null)
                {
                    line.OutChildren_Line.Add(this);
                    Slope = line.Slope;
                }
            }
        }
        [MultilingualCategory("Structure"), MultilingualDisplayName("AnchorPoint")]
        public PointBase PositionPoint
        {
            get { return InPoints[0]; }
            set { SetPoint(0, value); }
        }
        public override double NewSlope
        {
            get { return StraightLine.NewSlope; }
        }
        public override double NewPSlope
        {
            get { return StraightLine.NewPSlope; }
        }
        [Browsable(false)]
        public override AngleStringX RotateAngle
        {
            get
            {
                return base.RotateAngle;
            }

            set
            {
                base.RotateAngle = value;
            }
        }
        [Browsable(false)]
        public override RPointS RotateCenter
        {
            get
            {
                return base.RotateCenter;
            }

            set
            {
                base.RotateCenter = value;
            }
        }
        public override void CreateComponents()
        {
            if (PositionPoint == null)
            {
                PositionPoint = Pad.CreatePoint(Resources.Translate("AnchorPoint"), SpareCoordinate_);
                SpareCoordinate_ = PositionPoint.Pxy;//不加此句公式将不能正常显示
                Pad.TrackObj = this;
                base.CreateComponents();
            }
        }
    }
}
